package qq2564874169.tuaotuao.fx.app;

import org.springframework.boot.SpringApplication;
import qq2564874169.tuaotuao.fx.EventDispatcher;

import java.util.UUID;

public class MvcEvents {
    private final String firekey = UUID.randomUUID().toString();
    public final EventDispatcher<RequestEventArgs> evRequestBefore = new EventDispatcher<>(firekey);
    public final EventDispatcher<RequestEventArgs> evRequestAfter = new EventDispatcher<>(firekey);
    public final EventDispatcher<HandlerEventArgs> evHandlerBefore = new EventDispatcher<>(firekey);
    public final EventDispatcher<HandlerEventArgs> evHandlerAfter = new EventDispatcher<>(firekey);
    public final EventDispatcher<ActionEventArgs> evActionBefore = new EventDispatcher<>(firekey);
    public final EventDispatcher<ActionEventArgs> evActionAfter = new EventDispatcher<>(firekey);
    public final EventDispatcher<ActionErrorEventArgs> evActionError = new EventDispatcher<>(firekey);

    void onHandlerBefore(FxSpringApp app, HandlerEventArgs args) {
        evHandlerBefore.fire(firekey, app, args);
    }

    void onHandlerAfter(FxSpringApp app, HandlerEventArgs args) {
        evHandlerAfter.fire(firekey, app, args);
    }

    void onActionBefore(FxSpringApp app, ActionEventArgs args) {
        evActionBefore.fire(firekey, app, args);
    }

    void onActionAfter(FxSpringApp app, ActionEventArgs args) {
        evActionAfter.fire(firekey, app, args);
    }

    void onActionError(FxSpringApp app, ActionErrorEventArgs args) {
        evActionError.fire(firekey, app, args);
    }

    void onReuqestBefore(FxSpringApp app, RequestEventArgs args) {
        evRequestBefore.fire(firekey, app, args);
    }

    void onReuqestAfter(FxSpringApp app, RequestEventArgs args) {
        evRequestAfter.fire(firekey, app, args);
    }
}
